cd "~/Dropbox/ElevatorEffect/Reversals/JOP_Replication_Data/"

log using "NelsonHazeltonHinkle_JOP2020_replication.log"

*** Table A.2 Summarize average number of DJs in city where there is at least one CJ
use "sumCourthouses2010.dta", clear
sum djnum, detail
sort circuit
by circuit: sum djnum
clear


** Number of opinions in dataset
use "NelsonHazeltonHinkle_JOP2020_replication.dta", clear
keep caseID
duplicates drop
describe

use "NelsonHazeltonHinkle_JOP2020_replication.dta", clear

*** Text in Data and Methods section
** Distribution of outcome variable: vote to reverse
tab revVote
** Percentage of judges casting votes in same case who have chambers in the same courthouse
tab sameAddress

*** Figure 1
** For marginal effects used to produce Figure 1 see below starting at lines 71 and 89

*** Appendix A
** Appendix A, FN 2: Matching on all pre-treatment covariates (that vary within appellate judge)
cem fjcid(#0) aligned(#6) ideoLC(#0) panType(#0) qualIndex_LC(#2) sameLS(#0) civil_rights(#0) habeas(#0) female_LC(#0) minority_LC(#0) year if sameAddress != ., treatment(sameAddress)
tab cem_matched
rename cem_weights cem_weightsAlt
drop cem_strata cem_matched
** Matching Procedure Used Throughout Analysis
cem fjcid(#0) aligned(#6) if sameAddress != ., treatment(sameAddress) 
tab cem_matched
rename cem_weights cem_weightsMain
drop cem_strata 

*** Figure A.1
kdensity aligned if cem_matched == 1, addplot(kdensity aligned)
sum aligned, detail
drop cem_matched

*** Table A.1: Summary statistics
sum aligned qualIndex_LC3  caseload100 year qualIndex_LC3, detail
tab circuit
tab revVote
tab sameAddress 
tab ideoLC  
tab panType 
tab sameLS
tab DJdesig 
tab priorJud 
tab civil_rights
tab habeas 
tab female_LC 
tab minority_LC

*** Table A.2 (see above at line 7)

*** Appendix B

*** Table B.1

** Model 1: All Data
probit revVote c.aligned##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit 
estat ic
estimates store modA

* Marginal effects presented in the left panel of Figure 1
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
* Difference between marginal effects
di (b[1,1] - b[1,2])
* z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
* p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


** Model 2: Matched Data
probit revVote c.aligned##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit [iweight=cem_weightsMain]
estat ic
estimates store modM

* Marginal effects presented in the right panel of Figure 1
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
* Difference between marginal effects
di (b[1,1] - b[1,2])
* z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
* p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


*** Appendix B
** In-text discussion of predicted probability of vote to reverse when Aligned = 0.12
estimates restore modA
margins, at(sameAddress=(0 1) aligned=-0.12 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=(0 1) aligned=-0.12 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
count if aligned <= -.12
di 13626/35175

*** Figure B.1
*** All Data
** Base predicted probability of reversal
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8)

** Change in predicted probability for each variable
estimates restore modA
margins, at(sameAddress=0 aligned=(-0.30 0.33) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=(0 1) aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=(0 1) qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=(0 2) qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=(1 3) sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=(0 1) DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=(0 1) priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=(0 1) civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=(0 1) habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=(0 1) female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=(0 1) minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=(0 1) caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=(1.98 3.33) year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modA
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=(1980 2001) circuit=8) post contrast(atcontrast(ar._at))

** Figure B.1 (con.): Matched Data
** Base predicted probability of reversal
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8)

** Change in predicted probability for each variable
estimates restore modM
margins, at(sameAddress=0 aligned=(-0.30 0.33) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=(0 1) aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=(0 1) qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=(0 2) qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=(1 3) sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=(0 1) DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=(0 1) priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=(0 1) civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=(0 1) habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=(0 1) female_LC=0 minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=(0 1) minority_LC=0 caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=(0 1) caseload100=2.64 year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=(1.98 3.33) year=1991 circuit=8) post contrast(atcontrast(ar._at))
estimates restore modM
margins, at(sameAddress=0 aligned=0.03 ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.64 year=(1980 2001) circuit=8) post contrast(atcontrast(ar._at))

*** Appendix C

*** Table C.1 and Figure C.2
** Model 3: All Data
probit revVote c.aligned##c.sameAddress##c.ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit 
estat ic
estimates store mod1A

* Figure C.2, top right panel 
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=(1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(ideoLC=(1) sameAddress=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

* Figure C.2, top right panel 
estimates restore mod1A
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=(0) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(ideoLC=(0) sameAddress=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b


** Appendix C, dissusion in text: Marginal Effect of Aligned not different based ideological congruency of lower court ruling either in same or different courthouses
estimates restore mod1A
margins, dydx(aligned) at(ideoLC=(0 1) sameAddress=(1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

estimates restore mod1A
margins, dydx(aligned) at(ideoLC=(0 1) sameAddress=(0) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


*** Table C.1 and Figure C.2: Matched Data
probit revVote c.aligned##c.sameAddress##c.ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit [iweight=cem_weightsMain]
estat ic
estimates store mod1M

* Figure C.2, bottom left panel 
estimates restore mod1M
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=(1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(ideoLC=(1) sameAddress=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

* Figure C.2, bottom right panel 
estimates restore mod1M
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=(0) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(ideoLC=(0) sameAddress=(0 1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

** Appendix C, dissusion in text: Marginal Effect of Aligned not different based ideological congruency of lower court ruling either in same or different courthouses
margins, dydx(aligned) at(ideoLC=(0 1) sameAddress=(0) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

margins, dydx(aligned) at(ideoLC=(0 1) sameAddress=(1) panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


*** Appendix D

** Discussion in text
count if cfScore != . & sameAddress != .
di 8484/35179

count if cfScoreImp == . & sameAddress != .
di 5147/35179

** Matching using CF scores
cem fjcid(#0) alignedCF(#6) if sameAddress != ., treatment(sameAddress) 
rename cem_weights cem_weightsCF
drop cem_strata cem_matched

*** Tabe D.1 and data for Figure D.1
** Model 5: All Data
probit revVote c.alignedCF##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit 
estat ic
estimates store mod2A

* Figure D.1, left panel 
estimates restore mod2A
margins, at(sameAddress=(0 1) alignedCF=(-1.7(.2)1.7) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(alignedCF) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
di (b[1,1] - (b[1,2]))
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


** Moedl 6: Matched Data
probit revVote c.alignedCF##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit [iweight=cem_weightsCF]
estat ic
estimates store mod2M

* Figure D.1, right panel
estimates restore mod2M 
margins, at(sameAddress=(0 1) alignedCF=(-1.7(.2)1.7) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(alignedCF) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
di (b[1,1] - (b[1,2]))
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


*** Appendix E

** Discussion in text
count if sameCity == 1 & sameAddress == 0
di 431/35175
count if sameCity == 1
di 431/4109

*** Table E.1 and data for Figure E.1
** Model 7: All Data
probit revVote c.aligned##c.sameCity ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit 
estat ic
estimates store mod3A

** Matching Procedure Using Same City (instead of Same Address)
cem fjcid(#0) aligned(#6) if sameCity != ., treatment(sameCity) 
tab cem_matched
rename cem_weights cem_weightsCity
drop cem_strata cem_matched

* Figure E.1, left panel
estimates restore mod3A
margins, at(sameCity=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(sameCity=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

*** Table E.1 and data for Figure E.1
** Model 8: Matched Data
probit revVote c.aligned##c.sameCity ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year i.circuit [iweight=cem_weightsCity]
estat ic
estimates store mod3m

* Figure E.1, right panel
estimates restore mod3m
margins, at(sameCity=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
margins, dydx(aligned) at(sameCity=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 circuit=8)
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 


*** Main Model with no circuit fixed effects (robustness check discussed in the text of the article)
** Full Data
probit revVote c.aligned##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year 
estat ic
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991)
marginsplot, xdimension(aligned)
margins, dydx(aligned) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 )
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

** Matched Data
probit revVote c.aligned##c.sameAddress ideoLC i.panType qualIndex_LC3 sameLS DJdesig priorJud civil_rights habeas female_LC minority_LC caseload100 year [iweight=cem_weightsMain]
estat ic
margins, at(sameAddress=(0 1) aligned=(-.8(.2).8) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 )
marginsplot, xdimension(aligned)
margins, dydx(aligned) at(sameAddress=(0 1) ideoLC=1 panType=1 qualIndex_LC3=2 sameLS=0 DJdesig=0 priorJud=0 civil_rights=0 habeas=0 female_LC=0 minority_LC=0 caseload100=2.635 year=1991 )
matrix b = r(table)
** Difference between marginal effects
di (b[1,1] - b[1,2])
** z-test of difference between two marginal effects
di (b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2))
** p-value for z-test statistic
di 2*(1 - normal(abs((b[1,1] - (b[1,2]))/sqrt((b[2,1]^2)+(b[2,2]^2)))))
matrix drop b 

log close
